package com.ha7419x.rest;

import com.ha7419x.service.IDeptService;
import com.ha7419x.vo.Dept;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
public class DeptRest {

    @Resource
    private IDeptService deptService;
    @Resource
    private DiscoveryClient client; //eureka 发现服务

    @RequestMapping(value = "/dept/discover", method = RequestMethod.GET)
    public Object discover(){
        return this.client;
    }

    @RequestMapping(value = "/dept/get/{id}", method = RequestMethod.GET)
    public Object get(@PathVariable("id") Long id){
        return this.deptService.get(id);
    }

    @RequestMapping(value = "/dept/add", method = RequestMethod.POST)
    public Object get(@RequestBody Dept dept){
        return this.deptService.add(dept);
    }

    @RequestMapping(value = "/dept/list", method = RequestMethod.GET)
    public Object get(){
        return this.deptService.list();
    }
}
